//
//  CDFeedbackViewController.m
//  CollectToDesktop
//
//  Created by 王启颖 on 2020/10/16.
//  Copyright © 2020 godbe. All rights reserved.
//

#import "CDFeedbackViewController.h"

@interface CDFeedbackViewController ()
@property (weak, nonatomic) IBOutlet UITextView *feedTV;

@end

@implementation CDFeedbackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"返 回(2)"] forState:UIControlStateNormal];
    [button setFrame:CGRectMake(0, 0, 60, 40)];
    button.contentEdgeInsets = UIEdgeInsetsMake(0, -20,0, 0);
    [button addTarget:self action:@selector(navigationItemBack) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem =  item;
}

-(void)navigationItemBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)sendClick:(id)sender {
    if (self.feedTV.text.length==0) {
        [SVProgressHUD showImage:NULL_IMAGE status:@"请输入投诉内容~"];
        return;
    }
    [self request];
}

#pragma mark - 网络请求
-(void)request{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    dic[@"type"]=[NSNumber numberWithInt:2];
    dic[@"content"] = self.feedTV.text;
    NSString *urlstr=[NSString stringWithFormat:@"https://gapi.szlzyd.com/0010/na/product/suggest"];
    [[CDNetworkRequset HttpRequstManager] PostURL:urlstr params:dic success:^(NSInteger code, id  _Nonnull result) {
        [SVProgressHUD showImage:NULL_IMAGE status:@"客服人员会在24小时内处理投诉内容~"];
        [self.navigationController popViewControllerAnimated:YES];
    } fail:^(NSError * _Nonnull error) {
        
    }];
}

@end
